Skip to content

Remove doc comments for generate_trait_from_impl #20407

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

A4-Tacks
Copy link
Contributor

@A4-Tacks A4-Tacks commented Aug 8, 2025

Input:

struct Foo(f64);

impl F$0oo {
    /// Add `x`
    ///
    /// # Examples
    fn add(&mut self, x: f64) {
        self.0 += x;
    }
}

This PR:

struct Foo(f64);

trait NewTrait {
    /// Add `x`
    ///
    /// # Examples
    fn add(&mut self, x: f64);
}

impl NewTrait for Foo {
    fn add(&mut self, x: f64) {
        self.0 += x;
    }
}

Old:

struct Foo(f64);

trait NewTrait {
    /// Add `x`
    ///
    /// # Examples
    fn add(&mut self, x: f64);
}

impl NewTrait for Foo {
    /// Add `x`
    ///
    /// # Examples
    fn add(&mut self, x: f64) {
        self.0 += x;
    }
}

**Input**:

```rust
struct Foo(f64);

impl F$0oo {
    /// Add `x`
    ///
    /// # Examples
    fn add(&mut self, x: f64) {
        self.0 += x;
    }
}
```

**This PR**:

```rust
struct Foo(f64);

trait NewTrait {
    /// Add `x`
    ///
    /// # Examples
    fn add(&mut self, x: f64);
}

impl NewTrait for Foo {
    fn add(&mut self, x: f64) {
        self.0 += x;
    }
}
```

**Old**:

```rust
struct Foo(f64);

trait NewTrait {
    /// Add `x`
    ///
    /// # Examples
    fn add(&mut self, x: f64);
}

impl NewTrait for Foo {
    /// Add `x`
    ///
    /// # Examples
    fn add(&mut self, x: f64) {
        self.0 += x;
    }
}
```
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 8, 2025
@ChayimFriedman2
Copy link
Contributor

I'm not sure this is preferred. r-a does show the doc comment from the trait if there is none on the impl, but sometimes it's nicer to have it on the impl as well.

Although they could go out of sync...

@A4-Tacks
Copy link
Contributor Author

A4-Tacks commented Aug 8, 2025

Add another assistant to add documents from the trait?

@A4-Tacks
Copy link
Contributor Author

A4-Tacks commented Aug 9, 2025

Add another assistant to add documents from the trait?

Ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants